package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.operation.mscyb.bean.JqbzSettingsSop;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqbzSettingsSopMapper;
import com.jy.adscm.operation.mscyb.service.JqbzSettingsSopService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.zltx.bean.SjFile;
import com.jy.adscm.zltx.mapper.mysql.SjFileMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-05-20
 */
@Service
public class JqbzSettingsSopServiceImpl extends ServiceImpl<JqbzSettingsSopMapper, JqbzSettingsSop> implements JqbzSettingsSopService {
    @Autowired
    SjFileMapper sjFileMapper;
    @Override
    public List<SjFile> selectJqbzSettingsSopByPid(String pid) {
        List<SjFile> sjFiles=new ArrayList<>();
        Wrapper<JqbzSettingsSop> wrapper =new EntityWrapper<>();
        wrapper.eq("pid",pid);
        List<JqbzSettingsSop> jqbzSettingsSops = super.selectList(wrapper);
        for (JqbzSettingsSop jqbzSettingsSop : jqbzSettingsSops) {
            SjFile sjFile = sjFileMapper.selectById(jqbzSettingsSop.getCid());
            sjFiles.add(sjFile);
        }
        return sjFiles;
    }

    @Override
    public List<SjFile> selectAll() {
        Wrapper<SjFile> wrapper =new EntityWrapper<>();
        wrapper.eq("fileGs","生产一部");
        wrapper.eq("fileType","7");
        List<SjFile> sjFiles = sjFileMapper.selectList(wrapper);
        return sjFiles;
    }

    @Override
    public List<SjFile> selectByKeyWord(String keyword) {
        Wrapper<SjFile> wrapper =new EntityWrapper<>();
        wrapper.eq("fileGs","生产一部");
        wrapper.eq("fileType","7");
        wrapper.like("fileName",keyword);
        List<SjFile> sjFiles = sjFileMapper.selectList(wrapper);
        return sjFiles;
    }
}
